package com.woniuxy.woniumall.config;

import com.woniuxy.woniumall.intercepters.PermissionIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    PermissionIntercepter permissionIntercepter ;

    /*@Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> lists = new ArrayList<>();
        lists.add("/");
        lists.add("/login.html");
        lists.add("/user/login");
        lists.add("/user/getVerifyCode");
        lists.add("/book/**");
        lists.add("/asserts/**");
        lists.add("/my.html");

        registry.addInterceptor(permissionIntercepter)
                .addPathPatterns("/**")
                .excludePathPatterns(lists);

    }*/

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/my.html").setViewName("index");
        registry.addViewController("/book.html").setViewName("book");
        registry.addViewController("/cart.html").setViewName("cart");
        registry.addViewController("/order.html").setViewName("order");
        registry.addViewController("/user.html").setViewName("user");
        registry.addViewController("/cal.html").setViewName("cal");
    }
}
